package com.t.bricks.bussiness.db.entity.paylog.base;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;

import com.t.bricks.annotation.DataInfo;
import com.t.bricks.utils.function.data.MoneyUtil;
import com.t.bricks.utils.function.date.TimeUtil;
import com.t.bricks.utils.function.encode.MD5Util;

/**
 * 支付流水'PayLog'表实体类
 * 警告:非数据库字段禁止在此添加,应该创建扩展实体中添加
 * @author HuangXinBian
 */
@ApiModel("支付流水PayLog")
@DataInfo(sDbName="BricksMall", sTableName="PayLog")
public class PayLogBase implements Serializable {

	private static final long serialVersionUID = 1L;// 使用rmi时需修改

	/**
	 * 记录编号
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="PayLog",
		sName="uId", sComment="记录编号", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=true, isNull=false,
		iMaxLength=32, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=0 )
	@ApiModelProperty(value="记录编号", example="", position=0)
	//[end]
	protected String uId;

	/**
	 * 订单编号
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="PayLog",
		sName="sOrdersId", sComment="订单编号", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=32, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=1 )
	@ApiModelProperty(value="订单编号", example="", position=1)
	//[end]
	protected String sOrdersId;
	
	/**
	 * 支付金额
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="PayLog",
		sName="mMoney", sComment="支付金额", isDbField=true, sDbFileType="decimal",
		sDefaultData="0.00", isExtra=false, iskey=false, isNull=false,
		iMaxLength=10, isDecimal=false, iIntegralLength=6, iDecimalLength=2, iIndex=2 )
	@ApiModelProperty(value="支付金额", example="0.00", position=2)
	//[end]
	protected BigDecimal mMoney;

	/**
	 * 支付积分
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="PayLog",
		sName="iTally", sComment="支付积分", isDbField=true, sDbFileType="int",
		sDefaultData="0", isExtra=false, iskey=false, isNull=false,
		iMaxLength=100, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=3 )
	@ApiModelProperty(value="支付积分", example="0", position=3)
	//[end]
	protected Integer iTally;

	/**
	 * 顾客编号
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="PayLog",
		sName="sCustomerId", sComment="顾客编号", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=32, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=4 )
	@ApiModelProperty(value="顾客编号", example="", position=4)
	//[end]
	protected String sCustomerId;

	/**
	 * 顾客识别号
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="PayLog",
		sName="sCustomerNo", sComment="顾客识别号", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=20, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=5 )
	@ApiModelProperty(value="顾客识别号", example="", position=5)
	//[end]
	protected String sCustomerNo;

	/**
	 * 支付时间
	 */
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")//解决表单提交时字符串时间值错误
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="PayLog",
		sName="dPay", sComment="支付时间", isDbField=true, sDbFileType="datetime",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=23, isDecimal=false, iIntegralLength=-1, iDecimalLength=-1, iIndex=6 )
	@ApiModelProperty(value="支付时间", example="", position=6)
	//[end]
	protected Date dPay;

	/**
	 * 创建人
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="PayLog",
		sName="sCreator", sComment="创建人", isDbField=true, sDbFileType="varchar",
		sDefaultData="00000000", isExtra=false, iskey=false, isNull=false,
		iMaxLength=32, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=7 )
	@ApiModelProperty(value="创建人", example="00000000", position=7)
	//[end]
	protected String sCreator;

	/**
	 * 记录验证串
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="PayLog",
		sName="sRecordKey", sComment="记录验证串", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=32, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=8 )
	@ApiModelProperty(value="记录验证串", example="", position=8)
	//[end]
	protected String sRecordKey;

	/**
	 * 错误次数
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="PayLog",
		sName="iErrorCount", sComment="错误次数", isDbField=true, sDbFileType="int",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=100, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=9 )
	@ApiModelProperty(value="错误次数", example="", position=9)
	//[end]
	protected Integer iErrorCount;

	/**
	 * 取 记录编号
	 * @return String
	 */
	public String getuId() {
		return uId;
	}

	/**
	 * 设置记录编号
	 * @param uId
	 */
	public void setuId(String uId) {
		this.uId = uId;
	}

	/**
	 * 取 订单编号
	 * @return String
	 */
	public String getsOrdersId() {
		return sOrdersId;
	}

	/**
	 * 设置订单编号
	 * @param sOrdersId
	 */
	public void setsOrdersId(String sOrdersId) {
		this.sOrdersId = sOrdersId;
	}

	/**
	 * 取 支付金额
	 * @return Long
	 */
	public BigDecimal getmMoney() {
		return mMoney;
	}

	/**
	 * 设置 支付金额
	 * @param mMoney
	 */
	public void setmMoney(BigDecimal mMoney) {
		this.mMoney = mMoney;
	}

	/**
	 * 取 支付积分
	 * @return Integer
	 */
	public Integer getiTally() {
		return iTally;
	}

	/**
	 * 设置支付积分
	 * @param iTally
	 */
	public void setiTally(Integer iTally) {
		this.iTally = iTally;
	}

	/**
	 * 取 顾客编号
	 * @return String
	 */
	public String getsCustomerId() {
		return sCustomerId;
	}

	/**
	 * 设置顾客编号
	 * @param sCustomerId
	 */
	public void setsCustomerId(String sCustomerId) {
		this.sCustomerId = sCustomerId;
	}

	/**
	 * 取 顾客识别号
	 * @return String
	 */
	public String getsCustomerNo() {
		return sCustomerNo;
	}

	/**
	 * 设置顾客识别号
	 * @param sCustomerNo
	 */
	public void setsCustomerNo(String sCustomerNo) {
		this.sCustomerNo = sCustomerNo;
	}

	/**
	 * 取 支付时间
	 * @return Date
	 */
	public Date getdPay() {
		return dPay;
	}

	/**
	 * 设置支付时间
	 * @param dPay
	 */
	public void setdPay(Date dPay) {
		this.dPay = dPay;
	}

	/**
	 * 取 创建人
	 * @return String
	 */
	public String getsCreator() {
		return sCreator;
	}

	/**
	 * 设置创建人
	 * @param sCreator
	 */
	public void setsCreator(String sCreator) {
		this.sCreator = sCreator;
	}

	/**
	 * 取 记录验证串
	 * @return String
	 */
	public String getsRecordKey() {
		return sRecordKey;
	}

	/**
	 * 设置记录验证串
	 * @param sRecordKey
	 */
	public void setsRecordKey(String sRecordKey) {
		this.sRecordKey = sRecordKey;
	}

	/**
	 * 取 错误次数
	 * @return Integer
	 */
	public Integer getiErrorCount() {
		return iErrorCount;
	}

	/**
	 * 设置错误次数
	 * @param iErrorCount
	 */
	public void setiErrorCount(Integer iErrorCount) {
		this.iErrorCount = iErrorCount;
	}

	/**
	 * 创建当前'记录验证串'
	 * @param key 加密密钥
	 * @return String 子节点集合
	 */
	public String createRecordKey(String key) {
		StringBuilder sb = new StringBuilder(1000);
		
		sb.append(null != this.uId ? String.valueOf(this.uId) : "").append(";");
		sb.append(null != this.sOrdersId ? String.valueOf(this.sOrdersId) : "").append(";");
		sb.append(null != this.mMoney ? MoneyUtil.BigDecimal2String(this.mMoney, 2) : "").append(";");
		sb.append(null != this.iTally ? String.valueOf(this.iTally) : "").append(";");
		sb.append(null != this.sCustomerId ? String.valueOf(this.sCustomerId) : "").append(";");
		sb.append(null != this.sCustomerNo ? String.valueOf(this.sCustomerNo) : "").append(";");
		sb.append(null != this.dPay ? TimeUtil.toStr(this.dPay, "YYYY-MM-dd HH:mm:00") : "").append(";");
		sb.append(null != this.sCreator ? String.valueOf(this.sCreator) : "").append(";");
		sb.append(key);

		return MD5Util.MD5(sb.toString());
	}
	
	/**
	 * 复制对象
	 * @param source 数据源
	 * @return PayLogBase
	 */
	public static PayLogBase copy(PayLogBase source) {
		if (null == source) {
			return null;
		}
		
		PayLogBase target = new PayLogBase();
		target.setuId(source.getuId());
		target.setsOrdersId(source.getsOrdersId());
		target.setmMoney(source.getmMoney());
		target.setiTally(source.getiTally());
		target.setsCustomerId(source.getsCustomerId());
		target.setsCustomerNo(source.getsCustomerNo());
		target.setdPay(source.getdPay());
		target.setsCreator(source.getsCreator());
		target.setsRecordKey(source.getsRecordKey());
		target.setiErrorCount(source.getiErrorCount());

		return target;
	}
	
	/**
	 * 克隆对象
	 * @return PayLogBase
	 */
	public PayLogBase clone() {
		return copy(this);
	}
	
}
